package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 频道信息表 前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Autowired
    private WmChannelService  wmChannelService;


    @GetMapping("/channels")
    public ResponseResult findAll(){

        List<WmChannel> list = wmChannelService.list();
        return  ResponseResult.okResult(list);
    }

    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(WmNewsDto wmNewsDto){
        return wmChannelService.downOrUp(wmNewsDto);
    }

    @GetMapping("/del_news/{id}")
    public ResponseResult delNews(@PathVariable("id") Integer id){
        return wmChannelService.delNews(id);
    }
}
